package com.cskaoyan.user.controller;

import com.cskaoyan.mall.commons.result.ResponseData;
import com.cskaoyan.mall.commons.result.ResponseUtil;
import com.cskaoyan.user.constants.UserRetCode;
import com.cskaoyan.user.dto.UserVerifyRequest;
import com.cskaoyan.user.dto.UserVerifyResponse;
import com.cskaoyan.user.service.UserVerifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author sosog
 * @version 1.0.0
 * @description TODO
 * @date 2022/6/17 15:42
 */
@RestController
@RequestMapping("/user")
public class UserVerifyController {

    @Autowired
    UserVerifyService verifyService;

    /*
    TAMFYWNOWEUNOCWO
     */

    @GetMapping("/verify")
    public ResponseData verify(String username, String uuid) {
        UserVerifyRequest userVerifyRequest = new UserVerifyRequest();
        userVerifyRequest.setUserName(username);
        userVerifyRequest.setUuid(uuid);
        UserVerifyResponse verifyResponse = verifyService.verify(userVerifyRequest);
        if (verifyResponse.getCode().equals(UserRetCode.SUCCESS.getCode())) {
            return new ResponseUtil<>().setData(null);
        }
        return new ResponseUtil<>().setErrorMsg(verifyResponse.getMsg());

    }
}

